//判断用户是否设置了自动登陆功能
	if($.cookie("userInformation")){
		$("#register .first input").val($.cookie("userInformation").split("&")[0]);
		$("#register .second input").val($.cookie("userInformation").split("&")[1])
		$("#register .four input")[0].checked = true;
	}
	
// var date = new Date(); 
//var newDate = date.getTime() + (14 * 24 * 60 * 60 * 1000);
//date.setTime(date.getTime() + (14 * 24 * 60 * 60 * 1000)); 
//$.cookie("userId", 11, { path: '/', expires: newDate });
//console.log($.cookie("userId"))

//用户名失去焦点的操作
$("#register .first input").on("blur",function(){
	username("#register .first input","#register .first .msgdiv span")
})

//验证密码  
$("#register .second input").on("blur",function(){
	passwo("#register .second input","#register .second .msgdiv span");
})

//眼睛按钮用于看密码的状态
var loginNum = 0; 
$("#register .second  .iconfont").click(function(){
	loginNum += 1;
	if(loginNum % 2 == 1){
		$(this).siblings("input").attr("type","text")
	}else{
		$(this).siblings("input").attr("type","password")
	}
})
$("#register .four input").on("click",function(){
	
	
	
	
})

//用户点击登陆后登陆成功存储用户的userID和登录状态
$("#register .five div").on("click",function(){
	username("#register .first input","#register .first .msgdiv span");
	passwo("#register .second input","#register .second .msgdiv span");
	if(ok1 && ok2){
		var user = $("#register .first input").val();
		var pass = $("#register .second input").val();
		$.ajax({
			type:"POST",
			url:ptms.url.common.limitControl.register,
			data:{
				"username":user,
				"password":pass
			},
			success:function(data){
				if(data.code == 1){
					var date = new Date(); 
	    			var newDate = date.getTime() + (14 * 24 * 60 * 60 * 1000);
	    			var userId = data.data.user.userId;
//	    			$.cookie("userId",userId , { path: '/', expires: newDate });
					localStorage.setItem("userId",userId);
					
					//登陆成功后用于存储用户的信息，方便下次获取
					if($("#register .four input")[0].checked == true){
						var userInfor = $("#register .first input").val() + "&" + $("#register .second input").val();
						var date = new Date(); 
					    var newDate = date.getTime() + (14 * 24 * 60 * 60 * 1000);
					    date.setTime(date.getTime() + (14 * 24 * 60 * 60 * 1000)); 
					    $.cookie("userInformation", userInfor, { path: '/', expires: newDate });  
					    console.log( $.cookie("userInformation"));
						
					}else{
						$.cookie("userInformation", "", { path: '/' });
					}
					
					//登陆成功后本地cookie存储登陆的状态
					
					//localStorage.setItem("userId",data.data.user.userId);
//					$.cookie("loginState", "stateTrue", { path: '/', expires: newDate });
					//localStorage.setItem("loginState",true);
					window.location.href = "../index.html";
				}
			},
			error:function(data){
				console.log(data);
			},
			async:true
		});
	}
	
})
